package com.jsmtr.rms.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jsmtr.rms.service.IUtilService;

@Controller
@RequestMapping("/Common")
public class CommonController {
    @Resource
    private IUtilService utilService;

    //获得职业资格证类别
    @RequestMapping(value = "/getjndj", method = RequestMethod.GET)
    public void getJNDJ(HttpServletRequest request, HttpServletResponse response) {
        try {
            String pid = request.getParameter("pid").trim();
            int type = Integer.parseInt(request.getParameter("type").trim());
            if (type == 2) {
                if (pid.equals("1")) {
                    utilService.printTextResult(utilService.optionList("P", pid), response);
                } else if (pid.equals("2")) {
                    utilService.printTextResult(utilService.optionList("Q", pid), response);
                } else {
                    utilService.printTextResult("", response);
                }
            }
            if (type == 3) {
                String r = request.getParameter("r").trim();
                if (r.equals("1")) {
                    utilService.printTextResult(utilService.optionList("R", pid), response);
                } else {
                    utilService.printTextResult("", response);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printTextResult("", response);
        }
    }


    //获得专业技术资格
    @RequestMapping(value = "/getpostl", method = RequestMethod.GET)
    public void getPostLevel(HttpServletRequest request, HttpServletResponse response) {
        try {
            String pid = request.getParameter("pid").trim();
            utilService.printTextResult(utilService.optionList("J", pid), response);
        } catch (Exception e) {
            e.printStackTrace();
            utilService.printTextResult("", response);
        }
    }
}
